<%--
  Created by IntelliJ IDEA.
  User: HUAWEI
  Date: 2023/10/1
  Time: 13:31
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<div class=".container-fluid">
    <div class="container">
        <%--得到域对象中的news数据集合，使用forEach遍历集合--%>
        <c:forEach items="${newsList}" var="content">
            <div class="row" style="height: 220px">
                <div class="col">
                    <a href="${pageContext.request.contextPath}/newData?newDataId=${content.newsId}"
                       style="color: black;"
                       onmouseover="this.style.color='red';" onmouseout="this.style.color='black';">
                        <div class="pc">
                            <div class="row">
                                <div class="col">
                                    <div class="shadow p-1 mb-5 bg-white rounded">
                                            <%--遍历出集合中的对象调用对象里面相对应的属性--%>
                                        <div class="p-1 mb-2 bg-danger text-white">${content.newsTitle}</div>
                                        <div style="display: flex;align-items: flex-start">
                                            <img src="images/content-images/${content.newsImage}" alt="加载中" height="154px" width="273px"/>
                                            <div style="margin-left: 20px;">
                                                    ${content.newsContent}
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </a>
                </div>
            </div>
        </c:forEach>

            <nav aria-label="Page navigation example">
                <ul class="pagination justify-content-center">
                    <c:if test="${reqPageIndex != 1}">
                    <li class="page-item">
                        <a class="page-link"
                           href="${pageContext.request.contextPath}/news?reqNewsTypeId=${newsTypeId}&reqPageIndex=${reqPageIndex > 0 ? reqPageIndex - 1 : 1}">
                            <span aria-hidden="true">&laquo;</span>
                        </a>
                    </li>
                    </c:if>

                    <c:forEach begin="1" end="${pageCount}" var="pageNum">
                        <li class="page-item ${reqPageIndex == pageNum ? 'active' : ''}">
                            <a class="page-link"
                               href="${pageContext.request.contextPath}/news?reqNewsTypeId=${newsTypeId}&reqPageIndex=${pageNum}">
                                    ${pageNum}
                            </a>
                        </li>
                    </c:forEach>

                    <c:if test="${reqPageIndex != pageCount}">
                    <li class="page-item">
                        <a class="page-link"
                           href="${pageContext.request.contextPath}/news?reqNewsTypeId=${newsTypeId}&reqPageIndex=${reqPageIndex < pageCount ? reqPageIndex + 1 : pageCount}">
                            <span aria-hidden="true">&raquo;</span>
                        </a>
                    </li>
                    </c:if>

                    <li class="page-item disabled">
                        <span class="page-link">${total}条数据</span>
                    </li>
                    <li class="page-item disabled">
                        <span class="page-link">共${pageCount}页</span>
                    </li>
                </ul>
            </nav>

    </div>
</div>



